//
//  HLEConfig.m
//  DownloadM3U8Tool_Example
//
//  Created by hle1879 on 2020/8/29.
//  Copyright © 2020 134344. All rights reserved.
//

#import "HLEConfig.h"

@interface HLEConfig (){
    NSInteger _downloadRetries;
}

@end

@implementation HLEConfig
@synthesize downloadRetries;

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.downloadRetries = 0;//默认不重试
        self.supportBackground = NO;//默认不支持后台下载
        self.supportBrokenPointDownload = NO;//默认不支持断点下载
        self.maximumConnectionsPerHost = MAX_CONNECT_PERHOST;//默认支持的并发数量
    }
    return self;
}

+ (instancetype)defaultConfig{
    HLEConfig *config = [[HLEConfig alloc]init];
    return config;
}

-(instancetype)initWithDownloadRetries:(NSInteger)downloadRetries supportBackground:(BOOL)supportBackground supportBrokenPointDownload:(BOOL)supportBrokenPointDownload{
    self = [super init];
    if (self) {
        self.downloadRetries = downloadRetries;
        self.supportBackground = supportBackground;
        self.supportBrokenPointDownload = supportBrokenPointDownload;
        self.maximumConnectionsPerHost = MAX_CONNECT_PERHOST;
    }
    return self;
}

-(instancetype)initWithDownloadRetries:(NSInteger)downloadRetries supportBackground:(BOOL)supportBackground supportBrokenPointDownload:(BOOL)supportBrokenPointDownload maximumConnectionsPerHost:(NSInteger)maximumConnectionsPerHost{
    self = [super init];
    if (self) {
        self.downloadRetries = downloadRetries;
        self.supportBackground = supportBackground;
        self.supportBrokenPointDownload = supportBrokenPointDownload;
        self.maximumConnectionsPerHost = maximumConnectionsPerHost;
    }
    return self;
}

- (NSInteger)downloadRetries{
    return _downloadRetries;
}

-(void)setDownloadRetries:(NSInteger)downloadRetries{
    if (_downloadRetries < 0) {
        _downloadRetries = 0;
    }
    _downloadRetries = downloadRetries;
}

@end
